import 'package:ichinesereader/models/book/BookDetails.dart';
import 'package:ichinesereader/models/report/basketsResult.dart';
import 'package:ichinesereader/models/student/StudentMiniJson.dart';
import 'package:ichinesereader/models/common/Settings.dart';
import 'dart:convert';
import 'package:ichinesereader/models/teacher/TeacherAssessment.dart';

List<AssignmentDetail> assignmentDetailsFromJson(String str) =>
    List<AssignmentDetail>.from(
        json.decode(str).map((x) => AssignmentDetail.fromJson(x)));

String assignmentDetailsToJson(List<AssignmentDetail> data) =>
    json.encode(List<dynamic>.from(data.map((x) => x.toJson())));

class AssignmentDetail {
  AssignmentDetail({
    this.allStudentInClass,
    this.bookIds,
    this.books,
    this.classId,
    this.completedStudents,
    this.createDate,
    this.endDate,
    this.endDateUtc,
    this.extraPoints,
    this.id,
    this.instruction,
    this.instructionTrueOrFalse,
    this.name,
    this.noOfBookToBeRead,
    this.numBooks,
    this.settings,
    this.startDate,
    this.status,
    this.studentMiniJsoNs,
    this.studentUserNames,
    this.version,
    this.workType,
    this.writingCount,
    this.recordingCount,
    this.writingInfo,
    this.recordingInfo,
    this.undoneStudentList,
  });

  bool? allStudentInClass;
  List<String>? bookIds;
  List<BookDetails>? books;
  String? classId;
  int? completedStudents;
  int? createDate;
  int? endDate;
  int? endDateUtc;
  int? extraPoints;
  String? id;
  String? instruction;
  bool? instructionTrueOrFalse;
  String? name;
  int? noOfBookToBeRead;
  int? numBooks;
  Settings? settings;
  int? startDate;
  String? status;
  List<StudentMiniJson>? studentMiniJsoNs;
  List<String>? studentUserNames;
  String? version;
  String? workType;
  int? writingCount;
  int? recordingCount;
  BasketItem? writingInfo;
  BasketItem? recordingInfo;
  List<StudentA>? undoneStudentList;

  factory AssignmentDetail.fromJson(Map<String, dynamic> json) =>
      AssignmentDetail(
          allStudentInClass: json["allStudentInClass"],
          bookIds: json["bookIds"] != null
              ? List<String>.from(json["bookIds"].map((x) => x))
              : null,
          books: json["books"] != null
              ? List<BookDetails>.from(
                  json["books"].map((x) => BookDetails.fromJson(x)))
              : null,
          classId: json["classId"],
          completedStudents: json["completedStudents"],
          createDate: json["createDate"],
          endDate: json["endDate"],
          endDateUtc: json["endDateUtc"],
          extraPoints: json["extraPoints"],
          id: json["id"],
          instruction: json["instruction"],
          instructionTrueOrFalse: json["instructionTrueOrFalse"],
          name: json["name"],
          noOfBookToBeRead: json["noOfBookToBeRead"],
          numBooks: json["numBooks"],
          settings: json["settings"] != null
              ? Settings.fromJson(json["settings"])
              : null,
          startDate: json["startDate"],
          status: json["status"],
          studentMiniJsoNs: json["studentMiniJSONs"] != null
              ? List<StudentMiniJson>.from(json["studentMiniJSONs"]
                  .map((x) => StudentMiniJson.fromJson(x)))
              : null,
          studentUserNames: json["studentUserNames"] != null
              ? List<String>.from(json["studentUserNames"].map((x) => x))
              : null,
          version: json["version"],
          workType: json["workType"],
          writingCount: json["writingCount"],
          recordingCount: json["recordingCount"],
          writingInfo: json["writingInfo"] != null
              ? BasketItem.fromJson(json["writingInfo"])
              : null,
          recordingInfo: json["recordingInfo"] != null
              ? BasketItem.fromJson(json["recordingInfo"])
              : null,
          undoneStudentList: json["undoneStudentList"] != null
              ? List<StudentA>.from(
                  json["undoneStudentList"].map((x) => StudentA.fromJson(x)))
              : null);

  Map<String, dynamic> toJson() => {
        "allStudentInClass": allStudentInClass,
        "bookIds":
            bookIds != null ? List<dynamic>.from(bookIds!.map((x) => x)) : null,
        "books": books != null
            ? List<dynamic>.from(books!.map((x) => x.toJson()))
            : null,
        "classId": classId,
        "completedStudents": completedStudents,
        "createDate": createDate,
        "endDate": endDate,
        "endDateUtc": endDateUtc,
        "extraPoints": extraPoints,
        "id": id,
        "instruction": instruction,
        "instructionTrueOrFalse": instructionTrueOrFalse,
        "name": name,
        "noOfBookToBeRead": noOfBookToBeRead,
        "numBooks": numBooks,
        "settings": settings != null ? settings?.toJson() : null,
        "startDate": startDate,
        "status": status,
        "studentMiniJSONs": studentMiniJsoNs != null
            ? List<dynamic>.from(studentMiniJsoNs!.map((x) => x.toJson()))
            : null,
        "studentUserNames": studentUserNames != null
            ? List<dynamic>.from(studentUserNames!.map((x) => x))
            : null,
        "version": version,
        "workType": workType,
        "writingCount": writingCount,
        "recordingCount": recordingCount,
        "writingInfo": writingInfo != null ? writingInfo?.toJson() : null,
        "recordingInfo": recordingInfo != null ? recordingInfo?.toJson() : null,
        "undoneStudentList": undoneStudentList != null
            ? List<dynamic>.from(undoneStudentList!.map((x) => x.toJson()))
            : null
      };
}
